<template>
	<div class="use-record">
		<div>
			<label>{{ $t('route.DeviceManager') }}</label>
			<div></div>
			<button><img /><label>{{ $t('route.Usage_record') }}</label></button>
		</div>

		<div>
			<div>
			</div>

			<el-table class="table" :data="useRecordList" style="width: 100%">
				<el-table-column type="selection" width="55" />
				<el-table-column prop="workshop" :label="$t('route.Workshop')" />
				<el-table-column prop="proLine" :label="$t('route.Grou')" />
				<el-table-column prop="nickname" :label="$t('route.User')" />
				<el-table-column :label="$t('route.Usage_time')">
					<template #default="scope">
						{{scope.row.startTime}} {{ $t('route.reach') }} {{scope.row.endTime?scope.row.endTime:$t('route.so_far')}}
					</template>
				</el-table-column>
				<el-table-column prop="" :label="$t('route.Operation')" />
			</el-table>

			<div class="pagination">
				<el-pagination style="float: right;" background @current-change="handlePageChange" :current-page="query.pageNum"
					:page-size="query.pageSize" layout="total, prev, pager, next" :total="query.total"></el-pagination>
			</div>

		</div>


	</div>
</template>

<script>
	import http from "../../js/http/http.js";
	import api from "../../js/http/api.js";
	import CommonUtils from "../../js/common/common-utils.js";
	import Constant from '../../js/common/constant.js'

	export default {
		data() {
			return {
				deviceId: null,
				query: {
					pageNum: 1,
					pageSize: 10,
					total: 0,
				},
				useRecordList: [],
			};
		},
		methods: {
			jumpPage(type, param1) {
				if (type == 0) {
					this.$router.push({
						name: 'ADD_SCRAP_DEVICE',
						params: {
							deviceId: param1.id,
							repairId: param1.repairId,
						}
					});
				}
			},
			getUseRecordList() {
				http.post(api.GET_USE_RECORD_LIST, {
					deviceId: this.deviceId,
					pageNum: this.query.pageNum,
					pageSize: this.query.pageSize,
				}, data => {
					this.useRecordList = data.data.useRecordList;
					this.query.total = data.data.total;
				})
			},
			handlePageChange(pageNum) {
				this.query.pageNum = pageNum;
				this.getUseRecordList();
			},
			kindChange() {
				this.query.pageNum = 1;
				this.getUseRecordList();
			},
			searchClick() {
				this.query.pageNum = 1;
				this.getUseRecordList();
			},
		},
		created() {
			this.deviceId = CommonUtils.getParam(this, 'deviceId', 'setDeviceId');
			console.log('======' + this.deviceId)
			this.getUseRecordList();
		},
		mounted() {}
	};
</script>
<style lang="scss" scoped>
	.use-record {
		color: #444444;
		font-size: 18px;
		padding-right: 20px;
		height: calc(100vh - 100px);
		// overflow: scroll;
		scrollbar-width: none;
		/* firefox */
		-ms-overflow-style: none;
		/* IE 10+ */
		overflow-x: hidden;
		overflow-y: auto;

		>div:nth-of-type(1) {
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-top: 20px;
			background-color: #ffffff;
			padding: 20px;
			border-radius: 5px;

			>label:nth-of-type(1) {
				font-weight: 600;
			}

			>div:nth-of-type(1) {
				width: 1px;
				background-color: #cccccc;
				height: 15px;
				margin: 0px 20px;
			}

			>button:nth-of-type(1) {
				background-image: url(../../assets/img/customer-1.png);
				background-repeat: no-repeat;
				background-size: 100% 100%;
				padding: 5px 10px;
				border: 0px;
				display: flex;
				color: #ffffff;
				flex-direction: row;
				align-items: center;
				font-weight: 800;

				>img {
					margin-right: 7px;
					width: 15px;
					height: 15px;
					content: url(../../assets/img/customer-2.png);
				}
			}
		}

		>div:nth-of-type(2) {
			display: flex;
			flex-direction: column;
			margin-top: 20px;
			background-color: #ffffff;
			padding: 20px;
			border-radius: 5px;


			>div:nth-of-type(1) {
				display: flex;
				flex-direction: row;
				align-items: center;

				.div-handle-right {
					flex: 1;
					flex-direction: row-reverse;
					text-align: right;
					display: flex;
					align-items: center;

					>input:nth-of-type(1) {
						border: 1px solid #eeeeee;
						font-size: 15px;
						width: 150px;
						padding: 5px 8px;
						outline: none;
					}

					>button {
						color: #A866FF;
						margin-left: 10px;
						padding: 4px 20px;
					}
				}
			}

			.table {
				margin-top: 20px;
			}

		}

		.select {
			width: 120px;
			margin-top: 10px;
		}

		.echart {
			height: 150px;
			width: 100%;
		}

	}
</style>
